<%@ page import="top.sjydzq.www.bean.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>购物车 - 狗东电商 GD.COM</title>
    <link href="../css/before/daohang.css" rel="stylesheet" type="text/css" />
    <link href="../css/before/common.css" rel="stylesheet" type="text/css" />
    <link href="../css/before/style.css" rel="stylesheet" type="text/css" />
    <style>
        .btn {
            width: 100px;
            height: 30px;
            margin-left: 15px;
            background: #bb1700;
            border: none;
            color: #fff;
            border-radius: 5px;
        }
        .orange {
            background: #ff8b01;
        }
    </style>
</head>
<%
    User user = (User) session.getAttribute("user");

    int uid;
    if (user != null) {
        uid = user.getId();
    } else {
        uid = 0;
    }
%>
<body>
	<iframe src="/head" frameborder="0" width="100%"> </iframe>
	<div class="blank"></div>
	<div class="block clearfix">
		<!--当前位置-->
		<div class="location ared">
			当前位置： <a href="/">首页</a> > 购物车
		</div>
		<div class="blank"></div>
		<div>
			<div class="nFlowBox ared">
				<table width="99%" align="center" border="0" cellpadding="5"
					cellspacing="1" bgcolor="#dddddd">
					<tr>
						<th>商品信息</th>
						<th>单价（元）</th>
						<th>数量</th>
						<th>小计</th>
						<th>操作</th>
					</tr>
					<tr>
						<td colspan="5" height="15px"
							style="border: 0 none; background: #FFF"></td>
					</tr>
                    <c:forEach items="${cart.items}" var="item">
                        <tr>
                            <td bgcolor="#ffffff" align="center">
                                <a href="/product/detail?id=${item.productId}">
                                    <img style="width: 100px; height: 100px;" src="${item.productImg}" border="0" title="${item.productName}" />
                                </a><br />
                                <a style="text-decoration: none;" href="/product/detail?id=${item.productId}" class="f6">${item.productName}</a>
                            </td>
                            <td bgcolor="#ffffff" width="110px" align="center"><span>${item.productPrice}</span></td>
                            <td align="center" bgcolor="#ffffff" width="115px" valign="middle">
                                <form action="/cart/changeAmount">
                                    <input
                                        name="amount"
                                        type="text"
                                        value="${item.amount}"
                                        size="4"
                                        class="inputBg"
                                        style="text-align: center; width: 36px; color: #999999"
                                    />
                                    <input name="cid" value="${item.id}" type="text" hidden="hidden">
                                    <input name="uid" value="<%= uid %>" type="text" hidden="hidden">
                                    <button>更改</button>
                                </form>
                            </td>
                            <td align="center" bgcolor="#ffffff" width="115px">￥ ${item.subtotal}</td>
                            <td align="center" bgcolor="#ffffff" width="185px">
                                <a
                                    style="text-decoration: none;"
                                    href="/cart/remove?cid=${item.id}&uid=<%= uid %>"
                                    class="f6"
                                    title="删除"
                                >
                                    <img src="../images/before/sc.png" />
                                </a>
                            </td>
                        </tr>
                    </c:forEach>

					<c:if test="${cart.items.size() > 0}">
                        <tr>
                            <td align="right" bgcolor="#ffffff" colspan="4" height="41px;"
                                style="border-left: 0 none;">
                                购物金额总计(不含运费)
                                <font
                                        style="color: #a60401; font-size: 13px; font-weight: bold; letter-spacing: 0px;">
                                    ￥ <span id="stotal"><c:out value="${cart.money}" /></span>
                                </font>
                            </td>
                            <td align="center" bgcolor="#ffffff">
                                <a href="/cart/clear?uid=<%= uid %>" class="btn_blue_1">清空购物车</a>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#ffffff" colspan="4" align="right"
                                style="padding: 5px; padding-left: 2px; border-right: 0 none">
                                <a href="/">
                                    <button class="btn orange">继续购物</button>
                                </a>
                            </td>
                            <td bgcolor="#ffffff" align="center" style="border-left: 0 none; padding: 5px; padding-right: 2px;">
                                <a style="cursor: pointer;" href="/order/add?uid=<%= uid %>">
                                    <button class="btn">去结算</button>
                                </a>
                            </td>
                        </tr>
                    </c:if>
				</table>
			</div>
		</div>
	</div>
</body>
</html>
